<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var test = [
            {name:"zhang",age:"18",height:"180cm"},
            {name:"li",age:"19",height:"170cm"},
            {name:"wang",age:"14",height:"200cm"}
        ]
        // 给的是数组的每一项
        for (var i of test){
            console.log(i.age);
        } 
        // 给的是数组的下标
        console.log(test);
        for (var i in test){
            console.log(i);
        } 
        console.log(test);


    </script>
    

    <script>
        var arr =[2,3,4,5];
        var res0 = arr.map(item =>{
            return item*2;
        })
        console.log(res0);
        console.log(arr);

        var arr2 = [
            {name:"zhang",age:"18",height:"180cm"},
            {name:"li",age:"19",height:"170cm"},
            {name:"wang",age:"14",height:"200cm"}
        ]
        // map 可以改变数组每一个项，返回一个新的数组
        var res = arr2.map(item =>{
            return item["age"]=parseInt(item["age"])*2+"px";
        })
        console.log(arr2);
        console.log(res);
    </script>
</body>
</html>